//
//  NetworkLoadInView.m
//  BaseTdkc
//
//  Created by DavidHuang on 16/7/1.
//  Copyright © 2016年 黄栋炜. All rights reserved.
//

#import "NetworkLoadInView.h"
@interface NetworkLoadInView ()

@property (nonatomic, strong)UILabel *titleLb;
@property(nonatomic,strong)UIWebView * webView;

@end

@implementation NetworkLoadInView

-(instancetype)init{
    if (self = [super init]) {
        self.frame = CGRectMake(0, 0, screenW, screenH - pixelValue(100) - navHeight);
        [self addSubview:self.titleLb];
        [self addSubview:self.webView];
        [self layoutLocation];
    }
    return self;
}

- (UILabel *)titleLb {
    if (_titleLb == nil) {
        _titleLb = [[UILabel alloc] init];
        _titleLb.font = [UIFont fontSizeTwoText];
        _titleLb.textColor = [UIColor colorOfTwoTextColor];
        _titleLb.textAlignment = NSTextAlignmentCenter;
    }
    
    return _titleLb;
}

-(UIWebView *)webView{
    if (_webView == nil) {
        
        // 读取gif图片数据
        NSData *gif = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"Group-2" ofType:@"gif"]];
        // view生成
        _webView = [[UIWebView alloc] init];
        _webView.scalesPageToFit = YES;
        _webView.userInteractionEnabled = NO;//用户不可交互
        [_webView loadData:gif MIMEType:@"image/gif" textEncodingName:@"" baseURL:[NSURL URLWithString:@""]];
    }
    return _webView;
    
}

- (void)layoutLocation {
    WS(weakSelf)
    
    [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf).offset(pixelValue(300));
        make.centerX.mas_equalTo(weakSelf);
        make.width.height.mas_equalTo(pixelValue(180));
        
    }];
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.webView.mas_bottom).offset(pixelValue(28));
        make.centerX.mas_equalTo(weakSelf.webView);
    }];
    
}
-(void)setTitleLbStr:(NSString *)titleLbStr{
    _titleLbStr = titleLbStr;
    self.titleLb.text = titleLbStr;
    
}

@end
